BigDFT.UnitCells module

A module for handling unit cells for periodic calculations.

class UnitCell(cell=None, units='bohr')[source]

Defines a wrapper for unit cells.

Parameters
  • cell (list) – a list of unit cell vectors. This can either be a 3x1 list or a 3x3 list. Currently, only orthorhombic cells are supported. units (str): the units of the cell parameters. If cell is set to None, the free boundary condition is enforced.

  • units (str) – the unit of length.

get_boundary_condition(units='bohr')[source]

Get a string description of the boundary condition (i.e. free, surface, wire, periodic)

Parameters

units (str) – the units to report the cell in.

Returns

a string description of the boundary condition.

Return type

(str)

get_posinp(units='bohr')[source]

Create the dictionary representation of the cell that is passed to BigDFT.

Returns

a list of the three values of the unit cell.

Return type

(list)

minimum_image(pos, units='bohr')[source]

Given a vector of three positions, this wraps those positions inside the cell using the minimum image convention.

Returns

a list of the values of the wrapped position.

Return type

(list)

to_cartesian(pos)[source]

Convert a vector which is in reduced units to cartesian units.

Returns

the position in cartesian coordinates.

Return type

(list)

to_reduced(pos)[source]

Convert a vector which is in reduced units to cartesian units.

Returns

the position in reduced coordinates.

Return type

(list)

_example()[source]

The following is an example of module usage:

# Create a basic unit cell
cell = UnitCell([10, 8, 4], units="angstroem")

# Print out the posinp representation
print(cell.get_posinp())
print(cell.get_posinp(units="angstroem"))

# Right now we enforce the orthorhombic condition
try:
    cell = UnitCell([[10, 0, 0], [0, 8, 0], [0, 4, 10]])
except ValueError as e:
    print(e)
cell = UnitCell([[10, 0, 0], [0, 8, 0], [0, 0, 4]])
print(cell.get_boundary_condition("angstroem"))

# Wire boundary condition
wire = UnitCell([float("inf"), float("inf"), 4])
print(wire.get_posinp())
print(wire.get_boundary_condition())

# Surface boundary condition
surface = UnitCell([10, float("inf"), 4])
print(surface.get_posinp())
print(surface.get_boundary_condition())

# Wrap positions to the minimum image convention.
pos = [-5, -2, -3]
print(cell.minimum_image(pos))
print(wire.minimum_image(pos))
print(surface.minimum_image(pos))

pos = [15, 12, 13]
print(cell.minimum_image(pos))
print(wire.minimum_image(pos))
print(surface.minimum_image(pos))